Post

Replies

Boosts

Views

Activity

Comment on Not getting callback after tapping "Insert text" button in text on camera for UITextField
`import UIKit class ViewController: UIViewController {          override func viewDidLoad() {         super.viewDidLoad()                  setupTextField()     }          func setupTextField() {         let emailTextField = TextField(frame: CGRect(x: 150, y: 150, width: 150, height: 40))         emailTextField.textContentType = .emailAddress         emailTextField.keyboardType = .emailAddress         emailTextField.autocorrectionType = .no         emailTextField.layer.borderWidth = 1         emailTextField.delegate = self         self.view.addSubview(emailTextField)                  let textField = TextField(frame: CGRect(x: 150, y: 250, width: 150, height: 40))         textField.layer.borderWidth = 1         textField.delegate = self         textField.rightViewMode = .always         self.view.addSubview(textField)                  let button = UIButton(primaryAction: UIAction.captureTextFromCamera(responder: textField, identifier: nil))         button.frame = CGRect(x: 150, y: 300, width: 150, height: 60)         self.view.addSubview(button)     } } extension ViewController: UITextFieldDelegate {     func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {         print("Should change in chars delegate")         print(textField.text)         return true     }          func textFieldDidEndEditing(_ textField: UITextField) {         print("Did end editing delegate")         print(textField.text)     } } class TextField: UITextField {     override func insertText(_ text: String) {         super.insertText(text)         print("Insert tet function")         print(text)     }          override func unmarkText() {         super.unmarkText()         print("Unmark text function")         print(self.text)     }          override func setMarkedText(_ markedText: String?, selectedRange: NSRange) {         super.setMarkedText(markedText, selectedRange: selectedRange)         print("Marked text function")         print(markedText)     } }`
Jul ’21
Comment on Not getting callback after tapping "Insert text" button in text on camera for UITextField
Yes I have set the delegates too but that also don't get any response. `import UIKit class ViewController: UIViewController {          override func viewDidLoad() {         super.viewDidLoad()                  setupTextField()     }          func setupTextField() {         let emailTextField = TextField(frame: CGRect(x: 150, y: 150, width: 150, height: 40))         emailTextField.textContentType = .emailAddress         emailTextField.keyboardType = .emailAddress         emailTextField.autocorrectionType = .no         emailTextField.layer.borderWidth = 1         emailTextField.delegate = self         self.view.addSubview(emailTextField)                  let textField = TextField(frame: CGRect(x: 150, y: 250, width: 150, height: 40))         textField.layer.borderWidth = 1         textField.delegate = self         textField.rightViewMode = .always         self.view.addSubview(textField)                  let button = UIButton(primaryAction: UIAction.captureTextFromCamera(responder: textField, identifier: nil))         button.frame = CGRect(x: 150, y: 300, width: 150, height: 60)         self.view.addSubview(button)     } } extension ViewController: UITextFieldDelegate {     func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {         print("Should change in chars delegate")         print(textField.text)         return true     }     func textFieldDidEndEditing(_ textField: UITextField) {         print("Did end editing delegate")         print(textField.text)     } } class TextField: UITextField {     override func insertText(_ text: String) {         super.insertText(text)         print("Insert tet function")         print(text)     }     override func unmarkText() {         super.unmarkText()         print("Unmark text function")         print(self.text)     }     override func setMarkedText(_ markedText: String?, selectedRange: NSRange) {         super.setMarkedText(markedText, selectedRange: selectedRange)         print("Marked text function")         print(markedText)     } }`
Jul ’21